package com.jic.market.service;

import com.alibaba.excel.metadata.BaseRowModel;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.entity.PatchGrouponMpEntity;
import com.jic.market.entity.PromotionMerchantProductEntity;
import com.jic.market.impl.excel.ExcelListenerData;
import com.jic.market.orm.Pagination;
import com.jic.market.request.PatchGouponProductRequest;
import com.jic.market.request.PatchGroupProductAddAllProductRequest;
import com.jic.market.request.PatchGroupProductSaveV2Request;
import com.jic.market.request.PatchGroupPromotionProductQueryListV2Request;
import com.jic.market.request.manager.patchgroup.PatchGrouponProductSkuCountRequest;
import com.jic.market.request.rest.groupon.GrouponProductListRequest;
import com.jic.market.response.PatchGroupProductV2Response;
import com.jic.market.response.rest.groupon.GrouponProductInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * 拼团商家商品服务
 *
 * @author guohuayong
 * @date 2020/2/24 17:38
 **/
public interface PatchGroupMerchantProductService {

    /**
     * 查询商品信息
     * @param mpEntity
     * @return
     */
    PatchGrouponMpEntity query(PatchGrouponMpEntity mpEntityCondition);

    /**
     * 批量保存商品 list
     * @param productList
     * @return
     */
    Integer saveBatch(List<PatchGouponProductRequest> productList);

    /**
     * 批量保存商品V2 list
     * @param productList
     * @return
     */
    Integer saveBatchV2(List<PatchGroupProductSaveV2Request> productList);

    /**
     * 添加所有商品
     * @param addAllProductRequest
     * @return
     */
    Integer addAllProduct(PatchGroupProductAddAllProductRequest addAllProductRequest);


    /**
     * 查询促销商品列表
     * @param productCondition
     * @return
     */
    List<PatchGrouponMpEntity> findOfPage(
            PatchGrouponMpEntity productCondition,
            Pagination pagination);

    /**
     * 查询促销商品总数
     * @param productCondition
     * @return
     */
    Integer countOfPage(
            PatchGrouponMpEntity productCondition);


    /**
     * 批量删除促销商品
     * @param pgprList
     * @return
     */
    Integer deleteProductBatch(List<PatchGouponProductRequest> pgprList);

    /**
     * 批量删除促销商品V2
     * @param pgprList
     * @return
     */
    Integer deleteProductBatchV2(List<PatchGouponProductRequest> pgprList);

    /**
     * 根据 促销id 和 店铺ids 删除
     * @param promotionId
     * @param storeIds
     * @return
     */
    Integer deleteEntityListByPromotionIdAndStoreIdsBatch(
            @Param("promotionId") Long promotionId, @Param("storeIds") List<Long> storeIds);

    Integer update(PatchGouponProductRequest pgpr);

    Integer save(PatchGouponProductRequest request);

    /**
     * 根据促销id 和 商品id 删除促销商品
     * @param promotionId
     * @param mpId
     * @return
     */
    Integer deleteProduct(Long promotionId, Long mpId);

    /**
     * 促销商品表的主键 删除促销商品
     * @param patchGrouponMpId
     * @return
     */
    Integer deleteProductV2(Long patchGrouponMpId);

    /**
     * 导入 Excel（一个 sheet）到数据库
     * @param excel 需要导入的excel
     * @return
     */
    ExcelListenerData importMpExcel(MultipartFile excel, Long promotionId, BaseRowModel rowModel);


    /**
     * 批量保存商品数据
     * @param productList
     * @return
     */
    List<PatchGrouponMpEntity> saveBatchEntity(List<PatchGrouponMpEntity> productList);


    /**
     * 获取促销商品列表V2
     * @param ppqlRequest
     * @return
     */
    PageResult<PatchGroupProductV2Response> getPromotionProductListV2(
            PatchGroupPromotionProductQueryListV2Request ppqlRequest);


    /**
     * 获取促销商品列表FOR rest
     * @param request
     * @return
     */
    PageResult<GrouponProductInfo> getMpListForRest(GrouponProductListRequest request);

    /**
     * 查询sku数量
     * @param request
     * @return
     */
    Long skuCount(PatchGrouponProductSkuCountRequest request);

    /**
     * 查询商品列表
     * @param productCondition
     * @param pagination
     * @return
     */
    List<PatchGrouponMpEntity> findMutexOfPage(
            PatchGrouponMpEntity productCondition,
            Pagination pagination);

    Integer countMutexOfPage(
            PatchGrouponMpEntity productCondition);
}
